package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.domain.Analysis;
import com.tanhua.model.vo.LastYear;
import com.tanhua.model.vo.ThisYear;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface AnalysisMapper extends BaseMapper<Analysis> {
    //4.查询7日活跃总数
    @Select("select num_active from tb_analysis where record_date between #{sevenDaysAgo} AND NOW()")
    List<Integer> queryNumWeekActive(@Param("sevenDaysAgo") String sevenDaysAgo);
    //5.查询30日活跃总数
    @Select("select num_active from tb_analysis where record_date between #{thirtyDaysAgo} AND NOW()")
    List<Integer> queryNumMonthActive(@Param("thirtyDaysAgo") String thirtyDaysAgo);

    @Select("SELECT record_date as title,num_registered as amount FROM tb_analysis WHERE record_date between #{sd} and #{ed}")
    List<ThisYear> queryRegisterThis(@Param("sd") String sd, @Param("ed") String ed);


    @Select("SELECT record_date as title,num_active as amount FROM tb_analysis WHERE record_date between #{sd} and #{ed}")
    List<ThisYear> queryActiveThis(@Param("sd") String sd,@Param("ed") String ed);

    @Select("SELECT record_date as title,num_retention1d as amount FROM tb_analysis WHERE record_date between #{sd} and #{ed}")
    List<ThisYear> queryRetention1dThis(@Param("sd") String sd,@Param("ed") String ed);

    @Select("SELECT record_date as title,num_registered as amount FROM tb_analysis WHERE record_date between #{sd} and #{ed}")
    List<LastYear> queryRegisterLast(@Param("sd") String tbDateSd, @Param("ed") String tbDateEd);

    @Select("SELECT record_date as title,num_active as amount FROM tb_analysis WHERE record_date between #{sd} and #{ed}")
    List<LastYear> queryActiveLast(@Param("sd") String tbDateSd,@Param("ed") String tbDateEd);

    @Select("SELECT record_date as title,num_retention1d as amount FROM tb_analysis WHERE record_date between #{sd} and #{ed}")
    List<LastYear> queryRetention1dLast(@Param("sd") String tbDateSd,@Param("ed") String tbDateEd);

}
